﻿<?php

// add a new beverage
$new_beverage = array_merge( (array)json_decode(base64_decode($_POST['info'])), array('size'=>@$_POST['size'], 'sugar'=>@$_POST['sugar'], 'isDefault'=>false) );
$_SESSION['selection'][] = $new_beverage;

$beverages = $_SESSION['selection'];
$count = count($beverages);

$last = end($_SESSION['selection']);

echo Utils::breadCrumbs(array(
							array('label' => 'My beverage list', 'link' => 'preferences'), 
							array('label'=> 'Add new beverage', 'link'=>'additem'),
							array('label'=> 'Order summary')
						));
?>

<div class="sub_window">

	<?php 

	$message = Session::showLastFeedback();

	if ( empty($message) ):
	?>
	<h2>You just added a new beverage to your list!</h2>
	<p>Your order summary:</p>
	<img src="<?php echo $last['image_src']; ?>" alt="<?php echo $last['image_alt']; ?>" /><br/>
	<strong>Name: </strong><?php echo $last['name']; ?><br/>
	<strong>Size: </strong><?php echo $last['size']; ?><br/>
	<strong>Amount of sugar: </strong><?php echo isset($last['sugar']) ? $last['sugar'] : '-'; ?><br/>

	<?php 
	else: echo $message; endif;
	?>

	<p class="button_container">
		<img src="img/icons/cancel.png" class="button_icon"/><a class="button red" href="index.php?p=deleteselection&i=<?php echo $count; ?>" title="Cancel my order">Cancel my order</a>
		<img src="img/icons/ok.png" class="button_icon"/><a class="button green" href="index.php?p=preferences" title="Continue to my preferences page">Continue</a>
	</p>

</div>
